package com.smart.workflow.runners;

import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import com.smart.workflow.markers.EventRepository;
import com.smart.workflow.models.SMSInputEvent;
import com.smart.workflow.processors.SMSEventProcessor;

/**
 * Finds processes that wait for certain events. Amount of threads for runner
 * are controlled from event subscriber
 * 
 * @author Lukasz
 * 
 */
public class SMSRunner implements Runnable {

	@Resource(name="eventRepository")
	private EventRepository eventRepository;
	private SMSInputEvent smsInputEvent;

	public SMSRunner(Object event) {
		this.smsInputEvent = (SMSInputEvent)event;
	}

	@Override
	public void run() {
		System.out.println("SMSRunner");
		Collection<Object> affectedProcesses = eventRepository.processesForEvents(smsInputEvent);
		for (Object processor : affectedProcesses) {
			((SMSEventProcessor)processor).process(smsInputEvent);
		}
	}

}
